package com.gitee.huanminabc.fastboot.web.validation;

import com.gitee.huanminabc.fastboot.exception.ValidationException;
import com.gitee.huanminabc.fastboot.web.annotation.validation.NotBlank;
import com.gitee.huanminabc.nullchain.Null;

import java.lang.annotation.Annotation;

/**
 * @description:
 * @author: huanmin
 * @create: 2025-04-02 15:11
 **/
public class NotBlankValidationVerify implements ValidationVerify {
    @Override
    public Class<?> getAnnotation() {
        return NotBlank.class;
    }
    @Override
    public void verify(Object value, Annotation annotation,String gprmc) {
        NotBlank notBlank = (NotBlank) annotation;
        if (value == null) {
            throw new ValidationException(this.gprmcMerge(gprmc, notBlank.message()));
        }
        if (value instanceof String) {
            String message = (String) value;
            if (Null.is(message)) {
                throw new ValidationException(this.gprmcMerge(gprmc, notBlank.message()));
            }
        }
    }
}
